<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>沂水旅游-申请入驻</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css">
    <link rel="stylesheet" href="/static/index/css/base.css">
    <link rel="stylesheet" href="/static/index/css/my.css">

</head>
<body>

{include file="public/header" model='other' /}
{include file="public/myheader" model='other' /}

<div class="my-box-width">

    <div class="apply-form">

        <div class="backToMyOther">
            <a href="{:url('my/other')}">
                <img src="/static/index/images/back-icon.png" alt="">返回上一页
            </a>
        </div>

        <div class="apply-form-box">
            <div class="apply-form-title">
                景点入驻申请
            </div>

            <form action="" class="layui-form">


                <div class="form-kinds">

                    <div class="form-kinds-name">
                        景点基本信息
                    </div>

                    <div class="form-info">

                        <div class="layui-form-item">

                            <label class="layui-form-label">*景点名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="food_store_name" required  lay-verify="required" placeholder="填写景点名称" autocomplete="off" class="layui-input">
                            </div>

                        </div>

                        <div class="layui-form-item">

                            <label class="layui-form-label">*景点电话：</label>
                            <div class="layui-input-block">
                                <input type="text" name="food_store_tel" required  lay-verify="required" placeholder="填写景点电话" autocomplete="off" class="layui-input">
                            </div>

                        </div>

                        <div class="layui-form-item" id="area-picker">
                            <div class="layui-form-label">*景点地址：</div>
                            <div class="layui-input-inline" style="width: 150px;">
                                <select name="province" class="province-selector" lay-verify="required"  data-value="" lay-filter="province-1">
                                    <option value="">请选择省</option>
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width: 150px;">
                                <select name="city" class="city-selector" lay-verify="required"  data-value="" lay-filter="city-1">
                                    <option value="">请选择市</option>
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width:150px;">
                                <select name="county" class="county-selector" lay-verify="required"  data-value="" lay-filter="county-1">
                                    <option value="">请选择区</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">

                            <label class="layui-form-label"></label>
                            <div class="layui-input-block" style="width: 470px">
                                <input type="text" name="food_store_address" required  lay-verify="required" placeholder="输入详细地址" autocomplete="off" class="layui-input">
                            </div>

                        </div>

                        <div class="layui-form-item">

                            <label class="layui-form-label">*联系人手机号：</label>
                            <div class="layui-input-block">
                                <input type="text" name="send_tel" required  lay-verify="required" placeholder="此手机号用于接收结果通知" autocomplete="off" class="layui-input">
                            </div>

                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">*选择店铺类型：</label>
                            <div class="layui-input-block" style="width: 500px">
                                <input type="radio" name="food_store_tag" value="1" title="人文景观" checked>
                                <input type="radio" name="food_store_tag" value="2" title="自然景观">
                                <input type="radio" name="food_store_tag" value="3" title="温泉度假">
                                <input type="radio" name="food_store_tag" value="4" title="亲自游乐">
                            </div>
                        </div>

                    </div>

                </div>

                <div class="form-kinds">

                    <div class="form-kinds-name">
                        提交材料资质
                    </div>

                    <div class="form-info">

                        <div class="layui-form-item">
                            <label class="layui-form-label">*法人身份证照片：</label>
                            <div class="layui-input-block" style="width: 500px">
                                <a class="layui-btn apply-upload" id="up_fs_lagal_1">本地上传</a>
                                <input type="hidden" name="fs_lagal_1" id="fs_lagal_1">
                                <input type="hidden" name="fs_lagal_2" id="fs_lagal_2">
                                <input type="hidden" name="business_license" id="business_license">
                                <input type="hidden" name="live_action" id="live_action">
                            </div>
                            <div class="layui-input-block upload-tips" style="width: 600px">
                                （请法人有效的正式身份证（<span>正面</span>），请确保上传图片清晰无任何遮挡。请注意，身份证件有效 期应不少于3个月；临时身份证和已过期的身
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block" style="width: 500px">
                                <a class="layui-btn apply-upload" id="up_fs_lagal_2">本地上传</a>
                            </div>
                            <div class="layui-input-block upload-tips" style="width: 600px">
                                （请法人有效的正式身份证（<span>背面</span>），请确保上传图片清晰无任何遮挡。请注意，身份证件有效 期应不少于3个月；临时身份证和已过期的身
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">*营业执照照片：</label>
                            <div class="layui-input-block" style="width: 500px">
                                <a class="layui-btn apply-upload" id="up_business_license">本地上传</a>
                            </div>
                            <div class="layui-input-block upload-tips" style="width: 600px">
                                (请在您的营业执照（正本或副本）的上传照片加盖企业公章后，正向上传，请确保上传图片清晰无任何遮挡)
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">*上传实景照片：</label>
                            <div class="layui-input-block" style="width: 500px">
                                <a class="layui-btn apply-upload" id="up_live_action">本地上传</a>
                            </div>
                            <div class="layui-input-block upload-tips" style="width: 600px">
                                （请上传门店实景照片，请确保上传图片清晰无任何遮挡)
                            </div>
                        </div>


                    </div>


                </div>

                <div class="submit-button">

                    <button class="layui-btn apply-submit" lay-submit lay-filter="applySubmit">提交资料</button>

                </div>

            </form>
        </div>

    </div>

</div>

<div style="height: 100px"></div>

<script>

    var $ = layui.jquery;
        var layer = layui.layer
            , element = layui.element
            , upload = layui.upload
            , form = layui.form;

            form.render();


        layui.config({
                base: '/static/layuiadmin/modules/' //你的模块目录
            }).use(''); //加载入口 

        layui.use(['layarea'],function(){
            var layarea = layui.layarea
            layarea.render({
                    elem: '#area-picker',
                    data: {
                        province: '',
                        city: '',
                        county: '',
                    },
                    change: function (res) {
                        //选择结果
                        console.log(res);
                    }
                });
        });
        

        form.on('submit(applySubmit)', function(data){

            console.log(data.field);

            if (!data.field.fs_lagal_1 || !data.field.fs_lagal_2 || !data.field.business_license || !data.field.live_action ) {

                layer.msg('图片上传不完整',{icon:2,time:1000});

                return false;

            }

            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            $.ajax({
                url: "{:url('my/applyFood')}",
                type: 'post',
                dataType: 'json',
                data: {data:data.field},
                success: function(info){
                    if (info.code == 1) {
                        layer.msg('申请成功',{icon:1,time:2000},function(){
                            window.location.href = "{:url('my/other')}";
                        });
                    }else{
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })

        //普通图片上传
        upload.render({
            elem: '#up_fs_lagal_1'
            ,url: "{:url('My/uploadApplyImg')}"
            ,before:function(){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
            }
            ,done: function(res){
                layer.closeAll();
                if (res.code == 1){
                    return layer.msg(res.msg,{time:1500},function(){
                        $('#up_fs_lagal_1').html('已上传');
                        $('#fs_lagal_1').val(res.path);
                    });
                }else{
                    return layer.msg(res.msg);
                }
            }
        });

        //普通图片上传
        upload.render({
            elem: '#up_fs_lagal_2'
            ,url: "{:url('My/uploadApplyImg')}"
            ,before:function(){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
            }
            ,done: function(res){
                layer.closeAll();
                if (res.code == 1){
                    return layer.msg(res.msg,{time:1500},function(){
                        $('#up_fs_lagal_2').html('已上传');
                        $('#fs_lagal_2').val(res.path);
                    });
                }else{
                    return layer.msg(res.msg);
                }
            }
        });

        //普通图片上传
        upload.render({
            elem: '#up_business_license'
            ,url: "{:url('My/uploadApplyImg')}"
            ,before:function(){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
            }
            ,done: function(res){
                layer.closeAll();
                if (res.code == 1){
                    return layer.msg(res.msg,{time:1500},function(){
                        $('#up_business_license').html('已上传');
                        $('#business_license').val(res.path);
                    });
                }else{
                    return layer.msg(res.msg);
                }
            }
        });

        //普通图片上传
        upload.render({
            elem: '#up_live_action'
            ,url: "{:url('My/uploadApplyImg')}"
            ,before:function(){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
            }
            ,done: function(res){
                layer.closeAll();
                if (res.code == 1){
                    return layer.msg(res.msg,{time:1500},function(){
                        $('#up_live_action').html('已上传');
                        $('#live_action').val(res.path);
                    });
                }else{
                    return layer.msg(res.msg);
                }
            }
        });
</script>

</body>
</html>